#include "network.h"

int send_buf(int sockfd, char* buf, int len) {
  int i, t;
  for (i = 0; i < len; i += t) {
    t = send(sockfd, buf + i, len - i, 0);
    if (t == -1) return -1;
  }
  return 0;
}

int recv_buf(int sockfd, char* buf, int len) {
  int i, t;
  for (i = 0; i < len; i += t) {
    t = recv(sockfd, buf + i, len - i, 0);
    if (t == -1) return -1;
    if (t == 0) return 0;
  }
  return len;
}
